<?php
namespace Admin\Controller;
use Think\Controller;
class CatController extends Controller {
	private $cat='';
	public function __construct(){
		parent::__construct();
		$this->cat=D('Cat');
	}
    public function cateadd(){
        if(IS_POST){
            
            $res=$this->cat->cateadd(I('post.cat_id'),I('post.cat_name'),I('post.intro'),I('parent_id'));
            if($res){
            	$this->redirect('Admin/Cat/catelist');
            }
            
        }
        $this->display();
    }
    public function catelist(){
    	
    	$catlist=$this->cat->getCate();
    	
    	$this->assign('catlist',$catlist);
    	$this->display();
    }
    //修改cat表
    public function cateedit(){
    	
    	if(IS_POST){
    		
    		$row=$this->cat->cateEdit(I('post.cat_id'),I('post.cat_name'),I('post.intro'),I('post.parent_id'));
    		if($row){
    			$this->redirect('catelist');
    		}
    		
    	}
    	$catTree=$this->cat->getCate();
    	$cats=$this->cat->fineOne(I('get.cat_id'));
    	$this->assign('catTree',$catTree);
    	$this->assign('cats',$cats);
		$this->display();
        
    }

    public function catedel(){
       	
    	$row=$this->cat->delCate(I('get.cat_id'));
    	if($row){
    		$this->redirect('Admin/Cat/catelist');
    	}
    }
}
